import Vue from 'vue';
import store from "../../../../index";
export default {
    /*storeId:storeId*/
    /*裂变信息*/
    storeFissionApi(state,obj){
        let storeId = obj && obj.storeId ? obj.storeId : 0
        if(!storeId){
            storeId = this.getters.currentStoreFn && this.getters.currentStoreFn.storeId ? this.getters.currentStoreFn.storeId : 0
        }
        let url = `${Vue.prototype.NW_API_API_LOCALE_VERSION}/act/fission/store/website/${storeId}/get`;
        Vue.prototype.xurl.get(url).then((data) => {
            if (data.success) {
                state.fission = data.result;
                if(obj && obj.successFn){
                    obj.successFn(data.result)
                }
            } else if (data.errMsg) {
                console.log('storeFissionApi',data.errMsg)
            } else {
                console.log('获取裂变信息失败')
            }
        })
    },
    /*一键提现*/
    /* {
      "loginUserId": 10145,                         ----登录用户ID (与 登录第三方ID 必存在一个)
      "loginThirdId": 57884,                        ----登录第三方ID (与 登录用户ID 必存在一个)
      "actFissionId": 5,                            ----活动裂变ID
      "cashAmount": 26.6                            ----提现金额
    }*/
    getCashApi(state,obj){
        let storeId = obj && obj.storeId ? obj.storeId : 0;
        let userId = obj && obj.userId ? obj.userId : 0;
        let thirdId = obj && obj.thirdId ? obj.thirdId : 0;
        if(!userId){
            userId = this.getters.currentUserFn && this.getters.currentUserFn.userId ? this.getters.currentUserFn.userId : 0
        }
        if(!thirdId){
            thirdId = this.getters.currentThirdFn && this.getters.currentThirdFn.thirdId ? this.getters.currentThirdFn.thirdId : 0
        }
        console.log(userId,'userId');
        console.log(thirdId,'thirdId');
        let params = {
            "loginUserId": userId,
            "loginThirdId": thirdId,
            "actFissionId": obj && obj.actFissionId ? obj.actFissionId : 0,
            "cashAmount": obj && obj.cashAmount ? obj.cashAmount : 0
        };
        let url = `${Vue.prototype.NW_API_API_LOCALE_VERSION}/act/fission/onekey/confirm/cash`;
        Vue.prototype.xurl.postDataJsonLoading(url).then((data) => {
            if (data.success) {
                state.getMoney.getCash = data;
                if(obj && obj.successFn){
                    obj.successFn(data.result);
                }
            } else if (data.errMsg) {
                console.log('storeFissionApi',data.errMsg)
            } else {
                console.log('获取裂变信息失败')
            }
        })
    },
    /*查询参与用户的列表*/
    userJoinListApi(state,obj){
        let actFissionId = obj && obj.actFissionId ? obj.actFissionId : 0;
        let url = `${Vue.prototype.NW_API_API_LOCALE_VERSION}/act/fission/${actFissionId}/query/join/user?pageNum=1&pageSize=30`;
        Vue.prototype.xurl.post(url).then((data) => {
            if (data.success) {
                state.getMoney.joinList = data;
                if(obj && obj.successFn){
                    obj.successFn(data.result);
                }
            } else if (data.errMsg) {
                console.log('storeFissionApi',data.errMsg)
            } else {
                console.log('获取裂变信息失败')
            }
        })
    },
    /*查询助力成员列表*/
    fissionHelpListApi(state,obj){
        let actFissionId = obj && obj.actFissionId ? obj.actFissionId : 0;
        let userId = obj && obj.userId ? obj.userId : 0;
        let thirdId = obj && obj.thirdId ? obj.thirdId : 0;
        if(!userId){
            userId = this.getters.currentUserFn && this.getters.currentUserFn.userId ? this.getters.currentUserFn.userId : 0
        }
        if(!thirdId){
            thirdId = this.getters.currentThirdFn && this.getters.currentThirdFn.thirdId ? this.getters.currentThirdFn.thirdId : 0
        }
        let params = {
            loginUserId: userId,                        //----登录用户ID
            loginThirdId: thirdId                       //----登录第三方登录ID
        }
        let url = `${Vue.prototype.NW_API_API_LOCALE_VERSION}/act/fission/${actFissionId}/query/help/member/num/10`;
        Vue.prototype.xurl.post(url,params).then((data) => {
            if (data.success) {
                state.getMoney.helpList = data;
                if(obj && obj.successFn){
                    obj.successFn(data);
                }
            } else if (data.errMsg) {
                console.log('storeFissionApi',data.errMsg)
            } else {
                console.log('获取裂变信息失败')
            }
        })
    },
    /*查询自己的助力成员列表*/
    fissionSelfHelpListApi(state,obj){
        let actFissionId = obj && obj.actFissionId ? obj.actFissionId : 0;
        let userId = obj && obj.userId ? obj.userId : 0;
        let thirdId = obj && obj.thirdId ? obj.thirdId : 0;
        if(!userId){
            userId = this.getters.currentUserFn && this.getters.currentUserFn.userId ? this.getters.currentUserFn.userId : 0
        }
        if(!thirdId){
            thirdId = this.getters.currentThirdFn && this.getters.currentThirdFn.thirdId ? this.getters.currentThirdFn.thirdId : 0
        }
        let params = {
            loginUserId: userId,                        //----登录用户ID
            loginThirdId: thirdId,                         //----登录第三方登录ID
            pageNum: 1,                                 //----页码
            pageSize: 10,                               //----每页数量
        }
        let url = `${Vue.prototype.NW_API_API_LOCALE_VERSION}/act/fission/${actFissionId}/query/myself/has/amount/help/member`;
        Vue.prototype.xurl.post(url,params).then((data) => {
            if (data.success) {
                state.getMoney.selfHelpList = data;
                if(obj && obj.successFn){
                    obj.successFn(data);
                }
            } else if (data.errMsg) {
                console.log('storeFissionApi',data.errMsg)
            } else {
                console.log('获取裂变信息失败')
            }
        })
    },
    /*查询助力记录的列表*/
    selectHelpRecordApi(state,obj){
        let actFissionId = obj && obj.actFissionId ? obj.actFissionId : 0;
        let userId = obj && obj.userId ? obj.userId : 0;
        let thirdId = obj && obj.thirdId ? obj.thirdId : 0;
        if(!userId){
            userId = this.getters.currentUserFn && this.getters.currentUserFn.userId ? this.getters.currentUserFn.userId : 0
        }
        if(!thirdId){
            thirdId = this.getters.currentThirdFn && this.getters.currentThirdFn.thirdId ? this.getters.currentThirdFn.thirdId : 0
        }
        let params = {
            loginUserId: userId,                        //----登录用户ID
            loginThirdId: thirdId,                         //----登录第三方登录ID
        }
        let url = `${Vue.prototype.NW_API_API_LOCALE_VERSION}/act/fission/${actFissionId}/get/myself/help/count`;
        Vue.prototype.xurl.get(url,params).then((data) => {
            if (data.success) {
                state.getMoney.helpRecord = data;
                if(obj && obj.successFn){
                    obj.successFn(data);
                }
            } else if (data.errMsg) {
                console.log('storeFissionApi',data.errMsg)
            } else {
                console.log('查询助力记录失败')
            }
        })
    },
    /*查询助力统计列表*/
    helpStatisticsApi(state,obj){
        let actFissionId = obj && obj.actFissionId ? obj.actFissionId : 0;
        let userId = obj && obj.userId ? obj.userId : 0;
        let thirdId = obj && obj.thirdId ? obj.thirdId : 0;
        if(!userId){
            userId = this.getters.currentUserFn && this.getters.currentUserFn.userId ? this.getters.currentUserFn.userId : 0
        }
        if(!thirdId){
            thirdId = this.getters.currentThirdFn && this.getters.currentThirdFn.thirdId ? this.getters.currentThirdFn.thirdId : 0
        }
        let params = {
            pageNum: 1,                                 //----页码
            pageSize: 10,                               //----每页数量
        }
        let url = `${Vue.prototype.NW_API_API_LOCALE_VERSION}/act/fission/${actFissionId}/query/help/count`;
        Vue.prototype.xurl.get(url,params).then((data) => {
            if (data.success) {
                state.getMoney.statistics = data;
                if(obj && obj.successFn){
                    obj.successFn(data);
                }
            } else if (data.errMsg) {
                console.log('storeFissionApi',data.errMsg)
            } else {
                console.log('查询助力记录失败')
            }
        })
    },
}